package org.nightrunner.d3.controller.management;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.nightrunner.d3.constant.CRUDConstant;
import org.nightrunner.d3.service.ICategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Management Controller
 * 
 * @author NigthRunner
 * @date 2012-7-24
 * @version 1.0
 */
@Controller
@RequestMapping("management/")
public class ManagementController implements CRUDConstant {

	private static final String RETURN_VIEW_PREFIX = "management/";

	@Autowired
	public ICategoryService categoryService;

	public ICategoryService getCategoryService() {
		return categoryService;
	}

	public void setCategoryService(ICategoryService categoryService) {
		this.categoryService = categoryService;
	}

	@RequestMapping("")
	public String index(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
		return RETURN_VIEW_PREFIX + VIEW_INDEX;
	}

	@RequestMapping("/index")
	public String handle(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws Exception {
		return RETURN_VIEW_PREFIX + VIEW_INDEX;
	}

	@RequestMapping("/{fileName}.htm")
	public String handled(@PathVariable String fileName,
			HttpServletRequest request, HttpServletResponse response,
			ModelMap modelMap) throws Exception {
		return "management/" + fileName;
	}
}
